package cm.controller;

import cm.dto.XxlJobInfoQueryDTO;
import cm.service.XxlJobInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@Slf4j
@RestController
@RequestMapping("/xxlJob")
@Api(tags = "xxlJob相关接口", value = "xxlJob相关接口")
public class XxlJobController {

    @Autowired
    private XxlJobInfoService xxlJobInfoService;

    @ApiOperation(value = "导出所有Job列表")
    @PostMapping(value = "/exportAllJobsWithServiceName")
    public void exportAllJobsWithServiceName(HttpServletResponse response, @RequestBody XxlJobInfoQueryDTO xxlJobInfoQueryDTO) {
        xxlJobInfoService.exportAllJobsWithServiceName(response, xxlJobInfoQueryDTO);
    }

    @ApiOperation(value = "按照服务查找Job列表并导出")
    @GetMapping(value = "/exportJobsByServiceName")
    public void exportJobsByServiceName(HttpServletResponse response, @SpringQueryMap XxlJobInfoQueryDTO xxlJobInfoQueryDTO) {
        xxlJobInfoService.exportJobsByServiceName(response, xxlJobInfoQueryDTO);
    }
}
